from django.db import models

# Create your models here.

# import sys
# reload(sys)
# sys.setdefaultencoding('utf-8')

# 视频模型
class Video(models.Model):
    nid=models.AutoField(primary_key=True)
    title=models.CharField(max_length=512,default='该视频没有标题。。。')
    desc=models.CharField(max_length=1024,default='该视频暂没有描述。。。')
    Video_link=models.CharField(max_length=1024,verbose_name="视频链接",null=True)
    cover=models.CharField(max_length=255,default="/media/video/defaut.jpg")  #视频封面
    looks=models.IntegerField(verbose_name="浏览数", default=0)
    create_time = models.DateTimeField(auto_now_add=True,verbose_name="爬取时间")
    videoCategory=models.ForeignKey(to="VideoCg", to_field="nid")

    class Meta: # 用于在ADMIN中显示表名
        verbose_name = "视频"
        verbose_name_plural = verbose_name


# 视频类别
class VideoCg(models.Model):
    nid=models.AutoField(primary_key=True)
    name=models.CharField(max_length=1024,verbose_name="视频类别",default='未知类别')
    def __str__(self): # 用于在admin中，外键关联本模型时，显示外键关联的本模型的名字
        return self.name

    class Meta: # 用于在ADMIN中显示表名
        verbose_name = "视频分类"
        verbose_name_plural = verbose_name